#include <iostream>
using namespace std;

bool is_prime(int x)
{
    if (x == 1 ||x ==  0) return false;
    for (int i = 2; i <= x / i; i++)
    {
        if (x % i == 0) return  false;
    }
    return true;
}
bool solve(int x)
{
    if (!is_prime(x)) return false;
    while (x)
    {
        if (!is_prime(x % 10)) return false;
        x /= 10;
    }
    return true;
}
int main()
{
    int ret = 0;
    for (int i = 1; i <= 20210605; i++)
    {
        if (solve(i)) ret++;
    }
    cout << ret << endl;
    return 0;
}
